<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-3.6.0.js"></script>
    <script>
        $(function () {
            //给按钮添加点击事件
            $("#btn").click(function () {
                $.post("ajaxDemo",
                    // $.get("ajaxDemo",
                    //     {"name": $("#username").val()},
                    //     function (obt) {
                    //         $("#usernameMsg").html(obt)
                    //     },"text"
                    // );
                    $.post("ajaxDemo",
                        {"name": $("#username").val()},
                        function (obt) {
                            $("#usernameMsg").html(obt)
                        },"text"
                    );
            })
        })
    </script>
</head>
<body>
用户名:
<input name="username" id="username"/>
<span id="usernameMsg">   </span>
<input type="button" value="点击" id="btn"/>
</body>
</html>